package main;

/**
 * Main Class of Uebung 1
 * @author Patrick Bauer
 */
public class Uebung1 {

    /**
     * Local colorScheme variable
     */
    static int colorScheme = -1;

    /**
     * Checks for command line arguments and instances the mainframe
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        ColorScheme.init();

        //check first argument
        if(args.length == 0 || args[0].compareTo("funktionen") != 0) {        
            System.out.println("Please use \"funktionen\" as your first argument.");
            System.exit(1);
        }

        //check for second argument
        if(args.length > 1) {
            try{
                Uebung1.colorScheme = Integer.parseInt(args[1]);
                
                if(Uebung1.colorScheme < 0 || Uebung1.colorScheme > (ColorScheme.colorSchemes.length - 1)){
                    throw new NumberFormatException();
                }
                
            } catch (NumberFormatException e) {
                System.out.println("Please use a number between 0 and " + (ColorScheme.colorSchemes.length - 1) + " as your second argument.");
                System.exit(1);
            } 
        }
        
        //initialize frame
        MainFrame mainFrame = new MainFrame(Uebung1.colorScheme);
    }
}
